﻿
namespace OrderManage
{
    class Program
    {
        static void Main(string[] args)
        {
            var service = new OrderService();

            //添加订单
            var order1 = new Order { OrderId = 1, Customer = "一号测试" };
            order1.AddDetail(new OrderDetails { ProduceName = "小米15ultra", Quantity = 1, Price = 6999 });
            service.AddOrder(order1);

            //查询订单
            var getOrder1 = service.GetByOrderId(1);
            foreach (var order in getOrder1)
                Console.WriteLine(order + Environment.NewLine);

            //修改订单
            var updateOrder1 = new Order { OrderId = 1, Customer = "一号测试" };
            updateOrder1.AddDetail(new OrderDetails { ProduceName = "小米15ultra", Quantity = 2, Price = 6999 });
            service.UpdateOrder(updateOrder1);

            //再次查询订单
            var getOrder2 = service.GetByCustomer("一号测试");
            foreach (var order in getOrder2)
                Console.WriteLine(order + Environment.NewLine);

            //删除订单
            service.DeleteOrder(1);

            //再次查询订单
            var getOrder3 = service.GetByOrderId(1);
            if (!getOrder3.Any())
                Console.WriteLine("证明删除成功了");
            else
            {
                foreach (var order in getOrder3)
                    Console.WriteLine(order);
            }
        }

    }
}